package cn.bellychang.whiteboard;

/**
 * @author ChangLiang
 * @date 2021/3/11
 */
public class ExtendExecutionSequenceSolution {


}

class Parent{

    private static String A;

    static{
        A = "A";
        System.out.println("parent static field is initialized");
    }

    public Parent(){
        System.out.println("parent construct is initialized");
    }

    private String fieldA;

    //  在每次执行构造方法前先执行构造代码块
    {
        fieldA = "a";
        System.out.println("parent non-static field is initialized");
    }
}

class Sub extends Parent{
    private static String B;

    static{
        B = "B";
        System.out.println("sub static field is initialized");
    }

    public Sub(){
        System.out.println("sub construct is initialized");
    }

    private String fieldB;

    {
        fieldB = "b";
        System.out.println("sub non-static field is initialized");
    }

    public static void main(String[] args) {
        Sub sub = new Sub();
    }
}
